﻿
/**
*备案
*/
Chenxin.UI.RecordForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    actionUrl: 'service/markedHandler.ashx',
    id: 'recordWin',
    renderTo: 'jqm_record',
	defBBtn:true,
    initFormValidator: function() {
        var _this = this;
        $("#markedTime").focus(function() {
            WdatePicker({ oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        }).formValidator({ validatorgroup: this.id,
            onshow: "请输入时间！", onfocus: "请输入时间", oncorrect: " "
        }).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "时间不能为空!" }, onerror: "时间不能为空!"
        });
		/*$("#PropertyCode").formValidator({ validatorgroup: this.id, onshow: "请输产权证号", onfocus: "请输产权证号", oncorrect: "输入正确" 
		}).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "" }, onerror: "产权证号不能为空!"
        });
		$("#PropertyPersonName").formValidator({ validatorgroup: this.id, onshow: "请输产权人名", onfocus: "请输产权人名", oncorrect: "输入正确" 
		}).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "" }, onerror: "产权人名不能为空!"
        });
		*/
	    $("#markedNumber").formValidator({ validatorgroup: this.id, onshow: "请输备案号", onfocus: "请输备案号", oncorrect: "输入正确" }).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "" }, onerror: "备案号不能为空!"
        }).functionValidator({ //数字验证
            fun: function(val, elem) { return val.isNum(); }, onerror: "请输入数字"
        }).ajaxValidator({
            url: "service/markedHandler.ashx",
            datatype: "json",
            data: "houseid=" + _this.currentId + "&op=validate",
            success: function(data) {
                if (data.success == 0) {
                    return false;
                } else {
                    return true;
                }
            },
            buttons: $("#changeconfirmation_Save"),
            error: function() { alert("服务器没有返回数据，可能服务器忙，请重试"); },
            onerror: "备案号已存在！",
            onwait: "正在校验，请稍候..."
        });
        $("#markEndDay").focus(function() {
            WdatePicker({ oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        }).formValidator({ validatorgroup: this.id,
            onshow: "请输入时间！", onfocus: "请输入时间", oncorrect: " "
        }).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "时间不能为空!" }, onerror: "时间不能为空!"
        }).functionValidator({ //数字验证
            fun: function(val, elem) {
                if ($("#markStartDay").val() != "" && $("#markEndDay").val() != "") {
                    var d1 = new Date(Date.parse($("#markStartDay").val().replace(/-/g, "/")));
                    var d2 = new Date(Date.parse($("#markEndDay").val().replace(/-/g, "/")));
                    if ((d1.getTime() - d2.getTime()) > 0) {
                        return false;
                    } else {
                        return true;
                    }
                }
            }, onerror: "开始时间不能大于结束时间"
        });
        $("#markStartDay").focus(function() {
            WdatePicker({ oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
        }).formValidator({ validatorgroup: this.id,
            onshow: "请输入时间！", onfocus: "请输入时间", oncorrect: " "
        }).inputValidator({
            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "时间不能为空!" }, onerror: "时间不能为空!"
        }).functionValidator({ //数字验证
            fun: function(val, elem) {
                if ($("#markStartDausy").val() != "" && $("#markEndDay").val() != "") {
                    var d1 = new Date(Date.parse($("#markStartDay").val().replace(/-/g, "/")));
                    var d2 = new Date(Date.parse($("#markEndDay").val().replace(/-/g, "/")));
                    if ((d1.getTime() - d2.getTime()) > 0) {
                        return false;
                    } else {
                        return true;
                    }
                }
            }, onerror: "开始时间不能大于结束时间"
        });
    },
    createForm: function() {
		//return formCommon.houseRecordForm('markedbutton');
        return Chenxin.FormCommon.houseRecordForm('markedbutton');
    },
    initEvent: function() {
        var _this = this;
        $('#markedbutton_Save').live('click', function() {
            _this.save();
        });
        $('#markedbutton_Cancle').live('click', function() {
            _this.hide();
        });
    },
    initComponent: function() {
        Chenxin.UI.RecordForm.superclass.initComponent.call(this);
    }
});


/**
*@description 请求变更表单
*@comboIdPrefix DIV下拉框和提交按钮前缀
*/
Chenxin.FormCommon.houseRecordForm = function(comboIdPrefix) {
    return '<table class="tbl_f jqTabWh"><tbody> <tr><th style="width:100px; height:25px;">房源编号：</th><td style="width:440px;" ><input type="text" name="HouseCode" readonly="readonly" class="inputbox_n"/></td></tr><tr><th style="width:100px; height:25px;">地址：</th><td><input type="text" name="Address" readonly="readonly" class="inputbox_n"/></td></tr><tr><th style="width:100px; height:25px;">房源所属人员：</th> <td><input type="text" name="AddPerson" class="inputbox_n" readonly="readonly" /></td></tr><tr><th style="width:100px; height:25px;">房源所属门店：</th> <td><input type="text" name="AddDepart" class="inputbox_n" readonly="readonly" /></td></tr><tr><th style="width:100px; height:25px;">备案号：</th> <td style=" width:440px;"><div style="float:left"><input name="MarkCode"  class="inputbox_n" id ="markedNumber" maxlength="20" type="text"/></div><div style="float:left" id="markedNumberTip"></td></tr><tr><th style="width:100px; height:25px;">产权证号：</th> <td style=" width:440px;"><div style="float:left"><input name="PropertyCode"  class="inputbox_n" id ="PropertyCode" maxlength="20" type="text"/></div><div style="float:left" id="PropertyCodeTip"></td><tr><th style="width:100px; height:25px;">产权人名：</th> <td style=" width:440px;"><div style="float:left"><input name="PropertyPersonName"  class="inputbox_n" id ="PropertyPersonName" maxlength="20" type="text"/></div><div style="float:left" id="PropertyPersonNameTip"></td></tr><tr><th style="width:100px; height:25px;">备案日期：</th><td colspan="3"><div style="float:left"><input name="MarkDay" class="inputbox_n" id="markedTime"  readonly="readonly"  type="text" /></div><div style="float:left" id="markedTimeTip"></td></tr><tr><th style="width:100px;">备案开始日：</th><td><div style="float:left"><input type="text" name="MarkStartTime"  readonly="readonly"  value="" class="inputbox_n" id="markStartDay" /></div><div style="float:left" id="markStartDayTip" /></td></tr><tr><th style="width:100px;">备案结束日：</th><td><div style="float:left"><input name="MarkEndTime" readonly="readonly"  type="text" value="" class="inputbox_n" id="markEndDay" /></div><div style="float:left" id="markEndDayTip" /></td></tr></tbody> </table>'
}